/*---------------------------------------------------------------------------
Program Name    : MDBManager_bak
Division        : Connection Manager  
Desciprtion     : Single & Multi DBConnection Pool

Create by       : 
Create dt        : 
Modify			  : 
----------------------------------------------------------------------------*/
package com.swit.mobile.db;


import java.sql.*;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;

import  com.swit.mobile.db.DBManagerException;
import com.swit.mobile.jdf.Config;
import com.swit.mobile.jdf.Configuration;
import com.swit.mobile.servlet.CommonFunction;

public class DBManagerLog{

private static DBManagerLog 	instance;
private static Context 		ctx; 
private static DataSource 	ds;


/*---------------------------------------------------
		Get JDBC Driver
---------------------------------------------------*/
private DBManagerLog() throws DBManagerException{
	try{
		ctx = new InitialContext();
	    ds = (DataSource) ctx.lookup("mobile_log");
	}catch(Exception e){
		throw new DBManagerException(e.getMessage());
	}		
}

/*---------------------------------------------------
			Get Connection by Pool( Single connection )
---------------------------------------------------*/
public Connection getConnection() throws DBManagerException{
	
	return getConnection("mobile_log");
}

public Connection getConnection(String dbName) throws DBManagerException{
	Connection      conn    = null;	
	try{
		conn = ds.getConnection();
	}catch(Exception e){ 
		throw new DBManagerException("DBManager.getConnection() : " + e.getMessage());
	}
	return conn;
}

/*---------------------------------------------------
	Search and make Instance
---------------------------------------------------*/
public static synchronized DBManagerLog getInstance() throws DBManagerException{
try{
	if( instance == null )	instance = new DBManagerLog();
}catch(Exception e){
	throw new DBManagerException("DBManager.getInstance() : " + e.getMessage());
}

return instance;
}
}
